package com.lagou.sql.session;

import java.sql.SQLException;
import java.util.List;

/**
 * @author Kirito
 * @description: 封装对数据库的操作
 * @date 2020/03/25
 */
public interface SqlSession {
    /**
     * selectList
     *
     * @param statementId 用来确定执行的sql语句
     * @param params      参数，可能有
     * @param <E>         E
     * @return E
     */
    <E> List<E> selectList(String statementId, Object... params) throws Exception;

    /**
     * selectOne
     *
     * @param statementId String
     * @param params      Object
     * @param <T>         T
     * @return T
     * @throws Exception Exception
     */
    <T> T selectOne(String statementId, Object... params) throws Exception;

    /**
     * getMapper
     *
     * @param clazz Class
     * @param <T>   T
     * @return T
     */
    <T> T getMapper(Class<?> clazz);

    void insert(String statementId, Object... params) throws Exception;

    void update(String statementId, Object... params) throws Exception;

    void delete(String statementId, Object... params) throws Exception;

    /**
     * close
     *
     * @throws SQLException SQLException
     */
    void close() throws SQLException;
}
